#pragma strict

var snd : AudioClip;	// 사운드 파일
var explosion : Transform;
var explosion2 : Transform;

function OnTriggerEnter(coll : Collider)
{
	if(coll.gameObject.tag == "OBSTACLE")
	{
		AudioSource.PlayClipAtPoint(snd, transform.position);	// 사운드출력
		Instantiate(explosion2, coll.transform.position, Quaternion.identity);
		//Destroy(coll.gameObject);	// 장애물 제거
		Destroy(gameObject);		// 포탄제거
	}
	else if(coll.gameObject.tag == "WALL")
	{
		Instantiate(explosion, coll.transform.position, Quaternion.identity);
		//Destroy(coll.gameObject);	// 장애물 제거
		Destroy(gameObject);		// 포탄제거
	}
	else if(coll.gameObject.tag == "ENEMY")
	{
		Instantiate(explosion, gameObject.transform.position, Quaternion.identity);	// 충돌한 총알 위치에서 파티클 효과
		Destroy(gameObject);
		
		// score
		jsScore.hit++;
		if(jsScore.hit >= 5)
		{
			Destroy(coll.transform.root.gameObject);
		}
	}
	else if(coll.gameObject.tag == "USERTANK")
	{
		Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
		Destroy(gameObject);
		
		// score
		jsScore.lose++;
		if(jsScore.lose >= 5)
		{
			
		}
	}
}
